// 省市区请求接口
import request from "@/utils/request-mock";
import type {
  ProvincesModel,
  ProvincesListModel,
  CitiesModel,
  CitiesListModel,
  AreasModel,
  AreasListModel,
} from "@/types";

// 定义请求地址的枚举
enum Api {
  Provinces = "/Provinces",
  Cities = "/Cities",
  Areas = "/Areas",
}

/**
 * 获取所有省的信息
 * @param null
 * @returns 对应市的数据
 */

export const getProvincesApi = () => {
  return request.get<ProvincesListModel>(Api.Provinces);
};

/**
 * 获取所有市的信息
 * @param 省的编码
 * @returns 对应市的数据
 */

export const getCitiesApi = (province: string) => {
  return request.get<CitiesListModel>(Api.Cities + `?province=${province}`);
};

/**
 * 获取所有区/县的信息
 * @param 市的编码
 * @returns 对应区的数据
 */
export const getAreasApi = (city: string) => {
  return request.get<AreasListModel>(Api.Areas + `?province=${city}`);
};
